#pragma once

namespace NeuralBasic
{
	class Network;
}
namespace MnistDigit
{
	class Digit;
}

namespace Recognition
{

	class Trainer
	{
	public:
		Trainer(NeuralBasic::Network& m_network
			, std::vector<std::unique_ptr<MnistDigit::Digit>>& m_digits);
		~Trainer(void);
		void Start();
		void Stop();
		double GetError() const;
	private:
		void Epoch();
		void Item(const std::unique_ptr<MnistDigit::Digit>& digit);
		void CalculateError(const std::vector<double>& error);

		Trainer& operator=(const Trainer&);
		NeuralBasic::Network& m_network;
		std::vector<std::unique_ptr<MnistDigit::Digit>>& m_digits;

		std::vector<double> m_itemError;
		bool m_isStopped;
		volatile double m_error;
	};

}